package gwtmodule1.client.gui.shop;

import gwtmodule1.client.gui.PageShop.BasicCategoryItem;
import gwtmodule1.client.gui.utils.DekoTable;
import gwtmodule1.client.gui.utils.FrameClient;
import gwtmodule1.client.gui.utils.Title;

import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

public class PageSubCategory extends VerticalPanel implements FrameClient {

	private class ProductTable extends DekoTable {

		public ProductTable() {
			addTitle("Brand");
			addTitle("Product");
			addTitle("Size");
			addTitle("Price");
			addTitle("add to Cart");
		}

		public void addItem(String brand, String product, String size,
				float price) {
			AddRow r = addRow();
			r.add(brand);
			r.add(product);
			r.add(size);
			r.add(price, "USD");

			HorizontalPanel add = new HorizontalPanel();
			TextBox ammount = new TextBox();
			ammount.setWidth("32px");
			ammount.setTextAlignment(TextBox.ALIGN_RIGHT);
			ammount.setText("1");
			add.add(ammount);
			add.add(new Button("add"));

			r.add(add);
		}
	}

	private Title title = new Title("Sub Category");

	public PageSubCategory() {
		super();
		add(title);
		add(createTable());
	}

	private Widget createTable() {
		ProductTable table = new ProductTable();

		table.addItem("Microsoft", "XBox", "23x25x12", 300);
		table.addItem("Nintendo", "Wii", "small", 100);
		table.addItem("Sony", "Playstation 3", "10x10x10", 200);
		table.addItem("Sony", "CD-R", "700MB", 1.50f);

		return table;
	}

	public void onShow(Object param) {
		title.setTitle(((BasicCategoryItem) param).getName(" -> "));
	}

}
